package org.example.server.app.goods.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.frw.annotation.AppResponseFlag;
import org.example.server.app.goods.request.HomeCategoryListRequest;
import org.example.server.app.goods.response.category.CategoryTreeResponse;
import org.example.server.app.goods.service.CategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/categories")
@Slf4j
public class CategoryAppController {
  private final CategoryService categoryService;

  public CategoryAppController(CategoryService categoryService) {
    this.categoryService = categoryService;
  }

  @GetMapping(produces = "application/json")
  @AppResponseFlag
  public CategoryTreeResponse searchCategory(HomeCategoryListRequest request){
    log.info("received request: CategoryAppController.searchCategory. request={}",request);
    return categoryService.searchCategory(request);
  }
}
